/*
 * @Author: ujjldn ujjldn0515@163.com
 * @Date: 2025-07-14 18:55:27
 * @LastEditors: ujjldn ujjldn0515@163.com
 * @LastEditTime: 2025-08-03 13:39:34
 * @FilePath: \g-messagebox\vite.config.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { resolve } from 'path'

export default defineConfig({
  plugins: [
    vue(),
  ],
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src'),
    },
    extensions: ['.js', '.vue', '.json', '.ts'],
  },
  build: {
    target: 'esnext',
    outDir: 'dist',
    lib: {
      entry: './src/utils/useSelectDialog.js', 
      name: 'GDialog',
      fileName: (format) => `gdialog.${format === 'umd' ? 'umd.js' : 'min.js'}`,
      formats: ['umd'],
    },
    rollupOptions: {
      external: ['vue', 'element-plus'],
      output: {
        globals: {
          vue: 'Vue',
          'element-plus': 'ElementPlus'
        },
        // 自定义 CSS 文件输出名
        assetFileNames: (assetInfo) => {
          return 'gdialog.css'
        },
      },
    },
    define: {
      __VUE_OPTIONS_API__: true,
      __VUE_PROD_DEVTOOLS__: false,
      process: {
        env: {}
      }
    }
  },
})